const commonjs = require('@rollup/plugin-commonjs')
const typescript = require('rollup-plugin-typescript2')
const { cleandir } = require('rollup-plugin-cleandir')
const { nodeResolve } = require('@rollup/plugin-node-resolve')
const { eslint } = require("rollup-plugin-eslint")

const extensions = ['.js', '.ts']

module.exports = {
  input: 'src/index.ts',
  output: {
    file: 'bin/index.js',
    format: 'esm',
    // format: 'iife',
    // name: 'WeiQi'
  },
  plugins: [
    cleandir('./bin'),
    eslint(),
    typescript({
      tsconfigOverride: {
        compilerOptions: {
          module: "ESNext"
        }
      },
    }),
    nodeResolve({
      extensions,
      modulesOnly: true,
      preferredBuiltins: false
    }),
    commonjs()
  ]
};